﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AssessmentTool.PresentationLogic;
using System.Collections.ObjectModel;

namespace AssessmentTool.Controls
{
    public partial class ListaCompetenzaProfili : UserControl
    {
        Color backList = Color.FromArgb(255, 0, 71, 151);
        public ListaCompetenzaProfili()
        {
            InitializeComponent();
        }

        private void addCompetenza(String descrizione,String id)
        {
           
            Border b = new Border();
            b.Style = (Style)App.Current.Resources["HeaderBox2"];
            b.CornerRadius = new CornerRadius(0);
            b.BorderBrush = new SolidColorBrush(Colors.White);
            b.Background = new SolidColorBrush(backList);
            b.BorderThickness = new Thickness(0, 0, 0, 1);
            
            TextBlock t = new TextBlock();
            b.Height = t.Height;
            
            t.Style = (Style)App.Current.Resources["HeaderLabel"];
           // t.FontWeight = FontWeights.Bold;
            t.FontSize = 13;
            if (id.CompareTo("descrizione") != 0)
            {
                t.Margin = new Thickness(15, 2, 0, 0);
                t.Text = descrizione;
            }
            else
            {
                t.Text = descrizione;
                t.Margin = new Thickness(2, 2, 0, 0);
            }
            t.TextWrapping = TextWrapping.Wrap;
            
            t.Name = id;
            b.Child = t;
            Figli.Children.Add(b);
        }

        public void init(String header, String subHeader, List<String> competenze, String descrizione, String footer)
        {
            Header.Text = header;
            SubHeader.Text = subHeader;
            Descrizione.Text = descrizione;
            Footer.Text = footer;
            Figli.Children.Clear();
            addCompetenza(descrizione, "descrizione");
            foreach (String comp in competenze)
            {
                addCompetenza(comp, comp);
            }
            FooterBox.Visibility = String.IsNullOrEmpty(footer) ? Visibility.Collapsed : Visibility.Visible;
            HeaderBox.Visibility = String.IsNullOrEmpty(header) ? Visibility.Collapsed : Visibility.Visible;
            Figli.Visibility = competenze.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
            

        }


    }
}
